import { Component } from '@angular/core';
import { Button } from 'ionic-angular';
import { NavController } from 'ionic-angular';
import { Navbar } from 'ionic-angular';

// import { Http } from '@angular/http';
import {Http, Headers, RequestOptions} from '@angular/http';
import 'rxjs/add/operator/map';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController, public http: Http) {

  }

  leftButtonAction(){
    alert("wangbinbin");
    console.log("wangbinbin");

    // this.http.get('http://protest.xfzhi.com:88/userOperAction/logon?type=1&verify_code=1234567&user_phone=13478639584').map(res => res.json()).subscribe(data => {
    //     // this.posts = data.data.children;
    //     console.log(data.result);
    // });

    // NetWorkManager.m:158	http://protest.xfzhi.com:88/userOperAction/logon
    // NetWorkManager.m:159	{
    // type = 1,
    // verify_code = 1234567,
    // user_phone = 13478639584

    // var paras = {type : '1', verify_code : '1234567', user_phone : '13478639584'};

    //   // this.http.po

    //   this.http.post('http://protest.xfzhi.com:88/userOperAction/logon', paras).map(res => res.json()).subscribe(data => {
    //     // this.posts = data.data.children;
    //     console.log(data);
    // });


    let body = new FormData();
    body.append('type', '1');
    body.append('verify_code', '1234567');
    body.append('user_phone', '13478639584');

    // let body = JSON.stringify({
    //   type: '1',
    //   verify_code: '1234567',
    //   user_phone: '13478639584', 
    // });



    // let headers = new Headers({
    //   'NDAPI-Key': 'XXXXXXXXX',
    //   'NDAPI-Host': 'XXXXXXXXX' });
    // let options = new RequestOptions({ headers: headers });

    this.http
        .post('http://protest.xfzhi.com:88/userOperAction/logon', body)
        .map(res => res.json())
        .subscribe(
            data => {
              console.log(data);
            },
            err => {
              console.log("ERROR!: ", err);
            }
        );





  }

}

    


